Conditions | 5 |
Total Lines | 16 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 5 |
Changes | 0 |
1 | // Comparison functions for different data types |
||
43 | |||
44 | 1 | export function compareObjectKeys( |
|
45 | keyA: string | symbol, |
||
46 | keyB: string | symbol, |
||
47 | ascending: boolean |
||
48 | ): number { |
||
49 | 102 | if (typeof keyA === 'symbol' && typeof keyB === 'symbol') return 0; |
|
50 | 100 | if (typeof keyA === 'symbol') return 1; |
|
51 | 95 | if (typeof keyB === 'symbol') return -1; |
|
52 | |||
53 | 95 | const stringA = keyA as string; |
|
54 | 95 | const stringB = keyB as string; |
|
55 | |||
56 | 95 | return ascending |
|
57 | ? stringA.localeCompare(stringB) |
||
58 | : stringB.localeCompare(stringA); |
||
59 | } |
||
60 |